home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************************
- * This file handles all of the pop-up menu options. It updates the
- * menu when needed, and decides what parts were clicked on.
- **********************************************************************/
-
- #include "Creator Changer.h"
- #include "Creator Changer.menu.h"
-
-
- /**********************************************************************
- * Function Handle_pop_up_menu(), this function handles the events
- * given to the prefered types pop-up menu.
- **********************************************************************/
-
- void Handle_Pt_Pop_Up(DialogRef the_dialog, short menu_id, short creator, short file, short description)
- {
-
- Handle creator_handle, file_handle, desc_handle, menu_handle;
- short item_type, the_choice, the_item;
- Rect creator_rect, file_rect, the_rect;
- pref_types rsrc_handle;
- Str32 description_type;
- Str4 creator_type, file_type;
-
- GetDialogItem(the_dialog, menu_id, &the_item, &menu_handle, &the_rect);
-
- the_choice=GetControlValue((ControlHandle)menu_handle);
- if(the_choice)
- {
- UseResFile(CreatorChangerPref);
- rsrc_handle=**(pref_types **)GetResource(PREF_PT, The_pt_Type[the_choice]);
- if(description) p_Str_Copy(rsrc_handle.Description, description_type);
- p_Str_Copy(rsrc_handle.CreatorType, creator_type);
- p_Str_Copy(rsrc_handle.FileType, file_type);
- ReleaseResource((Handle)&rsrc_handle);
- UseResFile(CreatorChangerApp);
-
- if(description)
- {
- GetDialogItem(the_dialog, description, &item_type, &desc_handle, &file_rect);
- SetDialogItemText(desc_handle, description_type);
- }
-
- GetDialogItem(the_dialog, creator, &item_type, &creator_handle, &creator_rect);
- SetDialogItemText(creator_handle, creator_type);
-
- GetDialogItem(the_dialog, file, &item_type, &file_handle, &file_rect);
- SetDialogItemText(file_handle, file_type);
- }
- (**(ControlHandle)menu_handle).contrlValue=0;
- if(!description) Draw1Control((ControlHandle)menu_handle);
- PT_Item_To_Edit=the_choice;
-
- }
-
-
-
- /**********************************************************************
- * Function Make_Pop_Up_Menu(), this function makes the pop-up menu
- * for the prefered types menu.
- **********************************************************************/
-
- void Make_Pop_Up_Menu(short ID, OSType the_type, short num)
- {
-
- short item;
- MenuHandle menu_handle;
- pref_types **rsrc_handle_pt;
- auto_chng **rsrc_handle_ac;
-
- menu_handle=GetMenu(ID);
- DisposeMenu(menu_handle);
-
- menu_handle=GetMenu(ID);
- UseResFile(CreatorChangerPref);
- for(item=0;item<num;item++)
- {
- if(the_type==PREF_PT)
- {
- The_pt_Type[item+1]=item+Strt_Rsrc;
- rsrc_handle_pt=(pref_types **)GetResource(the_type, item+Strt_Rsrc);
- HLock((Handle)rsrc_handle_pt);
- InsertMenuItem(menu_handle, (**rsrc_handle_pt).Description, item+1);
- HUnlock((Handle)rsrc_handle_pt);
- ReleaseResource((Handle)rsrc_handle_pt);
- }
- else if(the_type==PREF_AC)
- {
- The_ac_Type[item+1]=item+Strt_Rsrc;
- rsrc_handle_ac=(auto_chng **)GetResource(PREF_AC, item+Strt_Rsrc);
- HLock((Handle)rsrc_handle_ac);
- InsertMenuItem(menu_handle, (**rsrc_handle_ac).Name, item+1);
- HUnlock((Handle)rsrc_handle_ac);
- ReleaseResource((Handle)rsrc_handle_ac);
- }
- }
- UseResFile(CreatorChangerApp);
-
- }
-
-
-
- /**********************************************************************
- * Function Handle_Ac_Pop_Up(), this function handles the events
- * given to the auto change pop-up menu.
- **********************************************************************/
-
- void Handle_Ac_Pop_Up(DialogRef the_dialog, short menu_id, short from_file_id, short to_creator_id, short to_file_id)
- {
-
- Handle the_handle, menu_handle;
- short the_type, the_choice, the_item;
- Rect the_rect;
- auto_chng rsrc_handle;
- Str16 name;
- Str4 from_file, to_creator, to_file;
-
- GetDialogItem(the_dialog, menu_id, &the_item, &menu_handle, &the_rect);
-
- the_choice=GetControlValue((ControlHandle)menu_handle);
- if(the_choice)
- {
- UseResFile(CreatorChangerPref);
- rsrc_handle=**(auto_chng **)GetResource(PREF_AC, The_ac_Type[the_choice]);
- p_Str_Copy(rsrc_handle.FromFile, from_file);
- p_Str_Copy(rsrc_handle.ToCreator, to_creator);
- p_Str_Copy(rsrc_handle.ToFile, to_file);
- ReleaseResource((Handle)&rsrc_handle);
- UseResFile(CreatorChangerApp);
-
- GetDialogItem(the_dialog, from_file_id, &the_type, &the_handle, &the_rect);
- SetDialogItemText(the_handle, from_file);
-
- GetDialogItem(the_dialog, to_creator_id, &the_type, &the_handle, &the_rect);
- SetDialogItemText(the_handle, to_creator);
-
- GetDialogItem(the_dialog, to_file_id, &the_type, &the_handle, &the_rect);
- SetDialogItemText(the_handle, to_file);
- }
- (**(ControlHandle)menu_handle).contrlValue=0;
- Draw1Control((ControlHandle)menu_handle);
- AC_Item_To_Edit=the_choice;
-
- }
-
-
-
- /**********************************************************************
- * Function Maintain_Menu_Items(), this function
- **********************************************************************/
-
- void Maintain_Menu_Items(WindowRef the_dialog)
- {
-
- if(the_dialog!=NIL_PTR)
- {
- if(the_dialog==Chng.dialog || the_dialog==Edit.dialog || the_dialog== Auto.dialog || the_dialog==Pref.dialog)
- {
- EnableItem(Apple_Menu, ENTIRE_MENU);
- DisableItem(File_Menu, ENTIRE_MENU);
- EnableItem(Edit_Menu, ENTIRE_MENU);
- }
- else if(the_dialog==About.dialog)
- {
- DisableItem(Apple_Menu, ENTIRE_MENU);
- DisableItem(Edit_Menu, ENTIRE_MENU);
- DisableItem(File_Menu, ENTIRE_MENU);
- }
- }
- else if(the_dialog==NIL_PTR)
- {
- EnableItem(Apple_Menu, ENTIRE_MENU);
- EnableItem(File_Menu, ENTIRE_MENU);
- DisableItem(Edit_Menu, ENTIRE_MENU);
- }
-
- DrawMenuBar();
-
- }